﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using homework2.PlaneFigure;

namespace homework2
{
    enum planeFigure { 
        Rectangle,
        Square,
        Circle
    }
    internal class Program
    {
        static void Main(string[] args)
        {
            Random random = new Random();
            double sum = 0;
            for (int i = 1; i <= 10;) { 
                planeFigure choice=(planeFigure)random.Next(0,3);
                switch (choice) { 
                    case planeFigure.Rectangle: 
                        {
                            int length = random.Next(0,10000);
                            int width=random.Next(0,10000);
                            PlaneFigure.PlaneFigure figue = new Rectangle(length, width);
                            if (figue.isLegal()) 
                            {
                                Console.WriteLine(i+":生成长为" + length + "宽为" + width + "的矩形");
                                Console.WriteLine();
                                sum += figue.getArea();
                                i++;
                            }
                            break;
                        }
                    case planeFigure.Square: 
                        {
                            int arcLength=random.Next(0, 10000);
                            PlaneFigure.PlaneFigure figue = new Square(arcLength);
                            if (figue.isLegal())
                            {
                                Console.WriteLine(i+":生成边长为" + arcLength + "的正方形");
                                Console.WriteLine() ;
                                sum += figue.getArea();
                                i++;
                            }
                            break;
                        }
                    case planeFigure.Circle: 
                        {
                            int radius=random.Next(0,10000);
                            PlaneFigure.PlaneFigure figure= new Circle(radius);
                            if (figure.isLegal())
                            {
                                Console.WriteLine(i + ":生成半径为" + radius + "的圆");
                                Console.WriteLine() ;
                                sum += figure.getArea();
                                i++;
                            }
                            break;
                        }
                }
            }
            Console.WriteLine("总面积为" + sum);
            Console.ReadKey();
        }
    }
}
